PhoneGap Essentials: Building Cross-Platform Mobile Apps (Fernando Lopez-Lezcano's Library) by John M. Wargo

PhoneGap Essentials: Building Cross-Platform Mobile Apps (Fernando Lopez-Lezcano's Library) by John M. Wargo

Author:John M. Wargo
Language: eng
Format: epub
Publisher: Addison-Wesley Professional
Published: 2012-10-17T04:00:00+00:00


Configuring Camera Options

Now that you know how to take pictures using the camera, let’s talk about options you can use to configure how the process works. As you may remember from the previous section, when calling getPicture, a developer can pass in a cameraOptions object that defines parameters controlling how the picture is obtained. The cameraOptions object supports the following properties:

• quality

• destinationType

• sourceType

• allowEdit

• encodingType

• targetWidth

• targetHeight

• mediaType

Each of these options will be described in greater detail in the following sections. Like with many other features of PhoneGap APIs, certain API options (such as allowEdit in the Camera API) apply on only a limited number of mobile platforms.

Here’s an example of a fully configured cameraOptions object you could use in one of your PhoneGap applications:

Click here to view code image

var cameraOptions = { quality : 75,

sourceType : Camera.PictureSourceType.CAMERA,

destinationType : Camera.DestinationType.FILE_URI,

allowEdit : true,

encodingType: Camera.EncodingType.JPEG,

targetWidth: 1024,

targetHeight: 768 };

When passed to the getPicture function, this cameraOptions object tells getPicture to get the picture from the camera (sourceType), return a file URI that points to the image file captured (destinationType), allow the user to edit the picture before returning it to the program (allowEdit), return the picture as a .jpeg file (encodingType), configure the encoded image file to use 75% image quality (quality), and set the image dimensions to 1024 by 768 pixels (targetWidth and targetHeight).

Now let’s describe each of the cameraOptions properties in greater detail.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.